package car;

import java.awt.*;

public class LinePanel {
    private static final int DEFAULT_TICK_STEP = 10;
    public static void drawLinePanel(Graphics2D g2, int x, int y, int width, int height, int max, int value, Color color) {
        g2.setColor(Color.BLACK);
        g2.drawRect(x, y, width, height);


        for (int i = 0; i <= max; i += max / DEFAULT_TICK_STEP) {
            int y1 = y + height - (i * height / max);
            g2.drawLine(x, y1, x + width, y1);

            String text = String.valueOf(i);
            TextPanel.drawTextPanel(g2, text, x + width + 10, y1 + 5);
        }


        int filledHeight = value * height / max;
        g2.setColor(color);
        g2.fillRect(x, y + height - filledHeight, width, filledHeight);
    }
}
